using System;
using System.Threading.Tasks;
using TaskTodo.Permissions;
using TaskTodo.Todos.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;

namespace TaskTodo.Todos
{
    public class TodoAppService : CrudAppService<Todo, TodoDto, long, PagedAndSortedResultRequestDto, TodoCreateDto, TodoUpdateDto>,
        ITodoAppService
    {
        protected override string GetPolicyName { get; set; } = TaskTodoPermissions.Todo.Default;
        protected override string GetListPolicyName { get; set; } = TaskTodoPermissions.Todo.Default;
        protected override string CreatePolicyName { get; set; } = TaskTodoPermissions.Todo.Create;
        protected override string UpdatePolicyName { get; set; } = TaskTodoPermissions.Todo.Update;
        protected override string DeletePolicyName { get; set; } = TaskTodoPermissions.Todo.Delete;

        private readonly ITodoRepository _repository;
        
        public TodoAppService(ITodoRepository repository) : base(repository)
        {
            _repository = repository;
        }

        /// <summary>
        /// 创建任务
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public override Task<TodoDto> CreateAsync(TodoCreateDto input)
        {
            return base.CreateAsync(input);
        }

        /// <summary>
        /// 加载一页任务
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public override Task<PagedResultDto<TodoDto>> GetListAsync(PagedAndSortedResultRequestDto input)
        {
            return base.GetListAsync(input);
        }

        /// <summary>
        /// 删除一条任务
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public override Task DeleteAsync(long id)
        {
            return base.DeleteAsync(id);
        }

        /// <summary>
        /// 加载单个任务
        /// </summary>
        /// <param name="id">任务编号</param>
        /// <returns></returns>
        public override Task<TodoDto> GetAsync(long id)
        {
            return base.GetAsync(id);
        }

        /// <summary>
        /// 更新一个任务
        /// </summary>
        /// <param name="id">任务编号</param>
        /// <param name="input"></param>
        /// <returns></returns>
        public override Task<TodoDto> UpdateAsync(long id, TodoUpdateDto input)
        {
            return base.UpdateAsync(id, input);
        }
    }
}
